#ifndef SLIDEBUTTON_H
#define SLIDEBUTTON_H

#include <QDebug>
#include <QWidget>
#include <QPixmap>
#include <QSound>
#include <QPushButton>
#include <QPropertyAnimation>

class SlideButton : public QPushButton
{
    Q_OBJECT
public:
    explicit SlideButton(QString image_pathname, QString sound_pathname, int slide_distance, int ratio = 1);

    ~SlideButton();

signals:

private:
    // 按钮的滑动距离
    int slide_distance;

    // 按钮的音效
    QSound *sound;

    // 按钮的图片路径
    QString image_pathname;

public:
    // 是否处于动画阶段
    bool is_animation = false;

private:
    // 当前类的全部事件
    virtual bool event(QEvent *) override;

    // 鼠标按下事件
    void mousePressEvent(QMouseEvent *) override;

    // 鼠标释放事件
    void mouseReleaseEvent(QMouseEvent *) override;

private:
    // 下坠
    void downBounce();

    // 上弹
    void upBounce();

    // 设置按钮图片
    void setButtonImage(QString image_pathname);

};

#endif // SLIDEBUTTON_H
